﻿function ClientAddListNewsByGroup()
{
    belongSite=document.getElementById("drpSelectSiteForListNewsByGroup").options[document.getElementById("drpSelectSiteForListNewsByGroup").selectedIndex].value;
    Url=Portal.CMS.ListNewsByGroup.GetAddGroupNewUrl(belongSite).value;
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
    //FilterFunc();
}

function ClientSaveAddListNewsByGroup()
{
    belongSite=document.getElementById("txtBelongSite").value;
    Subject = document.getElementById("txtListNewsByGroup").value;
    Url = document.getElementById("txtUrl").value;
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    RetValue = Portal.CMS.AddListNewsByGroup.ServerSideAddListNewsByGroup(belongSite,language,Subject,Url).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientDeleteListNewsByGroup(ListNewsByGroupId)
{
    Msg=Portal.CMS.ListNewsByGroup.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.CMS.ListNewsByGroup.ServerSideDeleteListNewsByGroup(ListNewsByGroupId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    FilterFunc();
}

function ShowClientUpdateUrlForm(ListNewsByGroupId)
{
    Url=Portal.CMS.ListNewsByGroup.GetShowUpdateForm(ListNewsByGroupId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //FilterFunc();
}

function ClientSaveUpdateListNewsByGroup(ListNewsByGroupId)
{
    Subject = document.getElementById("txtListNewsByGroup").value;
    Url = document.getElementById("txtUrl").value;
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    RetValue = Portal.CMS.UpdateListNewsByGroup.ServerSideUpdateListNewsByGroup(language, ListNewsByGroupId, Subject, Url).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function ShowClientListNewsByGroupItemUrlForm(ListNewsByGroupId)
{
    Url=Portal.CMS.ListNewsByGroup.GetShowListNewsByGroupItemsForm(ListNewsByGroupId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}


function ClientShowAddListNewsByGroupItemRootForm(ListNewsByGroupId)
{
    Url=Portal.CMS.ListNewsByGroupItems.GetAddListNewsByGroupItemFormUrl(ListNewsByGroupId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}

function ClientShowAddListNewsByGroupItemSubForm(ListNewsByGroupId,ParentListNewsByGroupItemId)
{
    Url=Portal.CMS.ListNewsByGroupItems.GetAddSubListNewsByGroupItemFormUrl(ListNewsByGroupId,ParentListNewsByGroupItemId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}



function ClientShowUpdateListNewsByGroupItemSubForm(ListNewsByGroupId,ListNewsByGroupItemId)
{
    Url=Portal.CMS.ListNewsByGroupItems.GetUpdateSubListNewsByGroupItemFormUrl(ListNewsByGroupId,ListNewsByGroupItemId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}

function ClientSaveAddListNewsByGroupItem(ListNewsByGroupId)
{
    MaxItems=document.getElementById("txtMaxItems").value;
    SaveItems=Portal.CMS.AddListNewsByGroupItem.CreateSaveItemsObject(MaxItems).value;
    for(var Index=0;Index<SaveItems.length;Index++)
    {
        SaveItems[Index].Title=document.getElementById("txtTitle_"+Index).value;
        SaveItems[Index].Checked=document.getElementById("checkBox_"+Index).checked;
        SaveItems[Index].IndexOrder=document.getElementById("txtIndexOrder_"+Index).value;
        SaveItems[Index].MaxItems=document.getElementById("txtMaxItem_"+Index).value;
        SaveItems[Index].GroupNewsItemId = document.getElementById("txtGroupNewsItemId_"+Index).value;
    }
    
    
    retValue=Portal.CMS.AddListNewsByGroupItem.ServerSideAddListNewsByGroupItems(ListNewsByGroupId,SaveItems).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    window.close();
}

function DeleteListNewsByGroupItem(ListNewsByGroupId,ListNewsByGroupIdItemId)
{
    ConfirmMsg=Portal.CMS.ListNewsByGroupItems.GetConfirmMsg().value;
    if(confirm(ConfirmMsg)==false)return;
    retValue=Portal.CMS.ListNewsByGroupItems.ServerSideDeleteListNewsByGroupItem(ListNewsByGroupIdItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    document.getElementById("divContentData").innerHTML=Portal.CMS.ListNewsByGroupItems.GetHtml(language,ListNewsByGroupId).value;
}

function ClientSaveListNewsByGroupItem(ListNewsByGroupId,ListNewsByGroupItemId)
{
    ListNewsByGroupItemName=document.getElementById("txtListNewsByGroupItemName").value;
    IndexOrder=document.getElementById("txtIndexOrder").value;
    retValue=Portal.CMS.UpdateListNewsByGroupItem.ServerSideListNewsByGroupItem(ListNewsByGroupItemId,ListNewsByGroupItemName,IndexOrder).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.close();
}

function ClientShowNewsItemForms(ListNewsByGroupId)
{
    Url=Portal.CMS.ListNewsByGroup.GetShowNewsItemForm(ListNewsByGroupId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
}


function DetectGroupNewsItem()
{
    selectedIndex=document.getElementById("divSelectGroupNews").selectedIndex;
    GroupNewsId=document.getElementById("divSelectGroupNews").options[selectedIndex].value;
    value=Portal.CMS.AddListNewsByGroupItem.GetGroupNewsText(GroupNewsId).value;
    document.getElementById("divContentGroupNews").innerHTML=value;
}

function ClientSaveListNewsByGroupItems()
{
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Max=document.getElementById("txtMaxGroupNewsRecordCount").value;
    for(var Index=0;Index<Max;Index++)
    {
        Id=document.getElementById("txtId_"+Index).value;
        Subject=document.getElementById("txtSubject_"+Index).value;
        IndexOrder=document.getElementById("txtIndexOrder_"+Index).value;
        MaxItem=document.getElementById("txtMaxItem_"+Index).value;
        
        Portal.CMS.ListNewsByGroupItems.ServerSideSaveListNewsByGroupItem(language,Id,Subject,IndexOrder,MaxItem).value;
    }   
    alert(Portal.CMS.ListNewsByGroupItems.ServerSideGetSaveOkMsg().value);
}


function DetectHtmlBody(ListNewsByGroupId)
{
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue=Portal.CMS.ListNewsByGroupItems.GetHtml(language,ListNewsByGroupId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divContentData").innerHTML=retValue;
}


function DetectUpdateListNewsByGroupBody(ListNewsByGroupId)
{
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue=Portal.CMS.UpdateListNewsByGroup.GetSubject(language,ListNewsByGroupId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("txtListNewsByGroup").innerHTML=retValue;
}

function ClientPublishing(ListNewsByGroupId)
{
    ConfirmMsg=Portal.CMS.ListNewsByGroup.GetConfirmPublishingMsg().value;
    if(confirm(ConfirmMsg)==false)return;

    document.getElementById("divProcessing").innerHTML=Portal.CMS.ListNewsByGroup.GetProcessingText().value;
    setTimeout("RealClientPublishing('"+ListNewsByGroupId+"')",10);
}

function RealClientPublishing(ListNewsByGroupId)
{
    retValue=Portal.CMS.ListNewsByGroup.ServerSidePublishing(ListNewsByGroupId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    alert(retValue);
}

function PublishingListNewsByGroupItem(ListNewsByGroupItemId)
{
    ConfirmMsg=Portal.CMS.ListNewsByGroupItems.GetConfirmPublishingMsg().value;
    if(confirm(ConfirmMsg)==false)return;

    document.getElementById("divProcessing").innerHTML=Portal.CMS.ListNewsByGroupItems.GetProcessingText().value;
 
    setTimeout("RealPublishingListNewsByGroupItem('"+ListNewsByGroupItemId+"')",10);
}

function RealPublishingListNewsByGroupItem(ListNewsByGroupItemId)
{
    retValue=Portal.CMS.ListNewsByGroupItems.ServerSideItemPublishing(ListNewsByGroupItemId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    alert(retValue);
}





function FilterFunc()
{
    document.getElementById("divProcessing").innerHTML=Portal.CMS.ListNewsByGroup.GetProcessingText().value;
    setTimeout("RealFilterFunc()",10);
}


function RealFilterFunc()
{
    belongSite=document.getElementById("drpSelectSiteForListNewsByGroup").options[document.getElementById("drpSelectSiteForListNewsByGroup").selectedIndex].value;
    retValue= Portal.CMS.ListNewsByGroup.GetHtml(belongSite).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divListNewsByGroupMain").innerHTML=retValue;
}


function ClientRefreshList(ListNewsByGroupId) {
    document.getElementById("divProcessing").innerHTML = Portal.CMS.ListNewsByGroupItems.GetProcessingText().value;
    setTimeout("RealClientRefreshList('"+ListNewsByGroupId+"')", 10);
}

function RealClientRefreshList(ListNewsByGroupId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    document.getElementById("divContentData").innerHTML = Portal.CMS.ListNewsByGroupItems.GetHtml(language, ListNewsByGroupId).value;
    document.getElementById("divProcessing").innerHTML = "";
}




function ClientSyncWithServer(ListNewsByGroupId) {
    if (confirm(Portal.CMS.ListNewsByGroup.GetConfirmSyncAllMsg().value) == false) {
        return;
    }
    document.getElementById("divProcessing").innerHTML = Portal.CMS.ListNewsByGroup.GetProcessingText().value;
    setTimeout("RealClientSyncWithServer('" + ListNewsByGroupId + "')", 10);
}

function RealClientSyncWithServer(ListNewsByGroupId) {
    rValue = Portal.CMS.ListNewsByGroup.ServerSideSyncWithServer(ListNewsByGroupId).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(rValue);
}